/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-通用处理层-任务调度
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.job.base;

import com.taiping.cc.job.dao.HttpParamConfigDAO;
import com.taiping.cc.job.dao.HttpRequestConfigDAO;
import com.taiping.cc.job.dao.HttpResponseConfigDAO;
import com.taipingframework.utility.context.BeanLifecycle;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.ExecutorService;

/**
 * 所有业务逻辑类的基类，
 * 为了消除引用DAO对象的重复编码，此处统一管理所有业务逻辑类对DAO引用
 */
public abstract class BaseService extends BeanLifecycle implements InitializingBean, DisposableBean {
    //region initMethod & destroyMethod - simple
    @Override
    protected void initMethod() {
        //something will be done at start up.
    }

    @Override
    protected void destroyMethod() {
        //something will be done at tear down.
    }
    //endregion

    //region InitializingBean & DisposableBean - simple
    @Override
    public void afterPropertiesSet() throws Exception {
        //something will be done at start up.
    }

    @Override
    public void destroy() throws Exception {
        //something will be done at tear down.
    }
    //endregion

    protected ExecutorService asyncExecutor;

    @Autowired
    public void setAsyncExecutor(ExecutorService asyncExecutor) {
        this.asyncExecutor = asyncExecutor;
    }

    protected HttpRequestConfigDAO httpRequestConfigDAO;
    protected HttpResponseConfigDAO httpResponseConfigDAO;
    protected HttpParamConfigDAO httpParamConfigDAO;

    @Autowired
    public void setHttpRequestConfigDAO(HttpRequestConfigDAO httpRequestConfigDAO) {
        this.httpRequestConfigDAO = httpRequestConfigDAO;
    }

    @Autowired
    public void setHttpResponseConfigDAO(HttpResponseConfigDAO httpResponseConfigDAO) {
        this.httpResponseConfigDAO = httpResponseConfigDAO;
    }

    @Autowired
    public void setHttpParamConfigDAO(HttpParamConfigDAO httpParamConfigDAO) {
        this.httpParamConfigDAO = httpParamConfigDAO;
    }

}
